"""
@ProjectName : StudentManagementSystem
@File        : student_service.py
@Author      : WorldWind(1772830365@qq.com)
@Address     : ChangSha - BoWeiFeng
@Date        : 2025/7/16 上午11:27
"""
from students.student_db import StudentDB


# 负责业务逻辑执行
class StudentService:
    def __init__(self):
        self.studentDB = StudentDB()
        print(f'This is __init__ method. {self.get_class_name()} class startup')

    # 根据学号或姓名查找学生
    def search(self, sno=None, name=None):
        return self.studentDB.search(sno, name)

    # 添加学生信息
    def add(self, student):
        return self.studentDB.add(student)

    # 修改学生信息
    def update(self, student):
        return self.studentDB.update(student)

    # 删除学生信息
    def delete(self, sno):
        return self.studentDB.delete(sno)

    @classmethod
    def get_class_name(cls):
        return cls.__name__

    def __del__(self):
        print(f'This is __del__ method. The {self.get_class_name()} class has been recycled')


if __name__ == '__main__':
    ss = StudentService()
    print(ss.search(sno='s003'))
